const {getAllAdmin,getAllAdminCount,updateAdmin,delAdmin,addAdmin,getOneAdmin,login3} = require('../../dao/admin/adminDao');

module.exports.getAllAdmin = async function(getParams){
    console.log(typeof getParams.currentPage);
    //如果当前页为0，则返回一个空数组
    if(parseInt(getParams.currentPage)>0){
        return await getAllAdmin(getParams);
    }else{
        return [];
    }
}

module.exports.getOneAdmin = async function(getParams){
    return await getOneAdmin(getParams);
}

module.exports.getAllAdminCount = async function(){
    return await getAllAdminCount();
}

// 登录
 module.exports.login2 = async (data)=>{
    return await login3(data);
 }
module.exports.updateAdmin = async function(postParams){
    const {nModified} = await updateAdmin(postParams);
    if(nModified===1){
        return true;
    }else{
        return false;
    }
}

module.exports.delAdmin = async function(postParams){
    const {deletedCount} = await delAdmin(postParams);
    if(deletedCount===1){
        return true;
    }else{
        return false;
    }
}

module.exports.addAdmin = async function(postParams){
    const res = await addAdmin(postParams);
    if(!res){
        return false;
    }else{
        return true;
    }
}
